#include "cslepui.h"
#include <QtGui>

void CSLEPUI::setupActions(){
	actionExit = new QAction(tr("Exit"),this);
	connect(actionExit, SIGNAL(triggered()), this, SLOT(close()));
	actionAddFiles = new QAction(tr("Add Files"),this);
	actionAbout = new QAction(tr("About CSLEP"),this);
	connect(actionAbout,SIGNAL(triggered()),this,SLOT(about()));

	actionLeastR = new QAction(tr("Least Squares loss"),this);
	connect(actionLeastR,SIGNAL(triggered()),this,SLOT(actLeastR()));
	actionNnLeastR = new QAction(tr("Least Squares loss (Non-negative Solution)"),this);
	actionLogisticR = new QAction(tr("Logistic loss"),this);
	actionNnLogisticR = new QAction(tr("Logistic loss (Non-negative Solution)"),this);

	actionLeastC = new QAction(tr("Least Squares loss"),this);
	actionNnLeastC = new QAction(tr("Least Squares loss (Non-negative Solution)"),this);
	actionLogisticC = new QAction(tr("Logistic loss"),this);
	actionNnLogisticC = new QAction(tr("Logistic loss (Non-negative Solution)"),this);

	actionLq1GlLeastR = new QAction(tr("Group Lasso (Least Squares loss)"),this);
	actionLq1GlLogisticR = new QAction(tr("Group Lasso (Logistic loss)"),this);
	actionLq1McLeastR = new QAction(tr("Multi-class(task) learning (Least Squares loss)"),this);
	actionLq1McLogisticR = new QAction(tr("Multi-class(task) learning (Logistic loss)"),this);
	actionLq1MtLeastR = new QAction(tr("Multi-task learning (Least Squares loss)"),this);
	actionLq1MtLogisticR = new QAction(tr("Multi-task learning (Logistic loss)"),this);

	actionL21McLeastC = new QAction(tr("Multi-class(task) learning (Least Squares loss)"),this);
	actionL21McLogisticC = new QAction(tr("Multi-class(task) learning (Logistic loss)"),this);
	actionL21MtLeastC = new QAction(tr("Multi-task learning (Least Squares loss)"),this);
	actionL21MtLogisticC = new QAction(tr("Multi-task learning (Logistic loss)"),this);

	actionFusedLasso = new QAction(tr("Fused Lasso with Least Squares loss"),this);

}


void CSLEPUI::setupMenus(){
	menuFile = menuBar()->addMenu(tr("&File"));
	menuFile->addAction(actionAddFiles);
	menuFile->addAction(actionExit);


	menuSolve = menuBar()->addMenu(tr("&Solve"));

	menuSolve->addAction(actionFusedLasso);
	menuL1Regularized = menuSolve->addMenu(tr("L1 Regularized"));
	menuL1Regularized->addAction(actionLeastR);
	menuL1Regularized->addAction(actionNnLeastR);
	menuL1Regularized->addAction(actionLogisticR);
	menuL1Regularized->addAction(actionNnLogisticR);

	menuL1Constrained = menuSolve->addMenu(tr("L1 Constrained"));
	menuL1Constrained->addAction(actionLeastC);
	menuL1Constrained->addAction(actionNnLeastC);
	menuL1Constrained->addAction(actionLogisticC);
	menuL1Constrained->addAction(actionNnLogisticC);

	menuLq1Regularized = menuSolve->addMenu(tr("Lq/L1 Regularized"));
	menuLq1Regularized->addAction(actionLq1GlLeastR);
	menuLq1Regularized->addAction(actionLq1GlLogisticR);
	menuLq1Regularized->addAction(actionLq1McLeastR);
	menuLq1Regularized->addAction(actionLq1McLogisticR);
	menuLq1Regularized->addAction(actionLq1MtLeastR);
	menuLq1Regularized->addAction(actionLq1MtLogisticR);

	menuL21Constrained = menuSolve->addMenu(tr("L2/L1 Constrained"));
	menuL21Constrained->addAction(actionL21McLeastC);
	menuL21Constrained->addAction(actionL21McLogisticC);
	menuL21Constrained->addAction(actionL21MtLeastC);
	menuL21Constrained->addAction(actionL21MtLogisticC);

	menuView = menuBar()->addMenu(tr("&View"));

	menuHelp = menuBar()->addMenu(tr("&Help"));
	menuHelp->addAction(actionAbout);

}



void CSLEPUI::setupWorkspacePanel(){
	dockWidgetWorkspace = new CSLEPFilesWorkspaceWidget(tr("Workspace"));
	dockWidgetWorkspace->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
	addDockWidget(Qt::RightDockWidgetArea, dockWidgetWorkspace);
	menuView->addAction(dockWidgetWorkspace->toggleViewAction());
}

void CSLEPUI::actLeastR(){
	optsWidget->show();
}